//
//  BaseTableViewController.swift
//  HYYWeibo
//
//  Created by HY-Mac on 16/7/9.
//  Copyright © 2016年 HY-Mac. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {
    
    
    var userLogin = AccountViewModel().userLogin
    var visitorLoginView: VisitorLoginView?

    override func loadView() {
        
        userLogin ? super.loadView() : loadOtherView()

        
    }
    private func loadOtherView(){
        
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.visitorDelegate = self
        //otherView.backgroundColor = UIColor.grayColor()
        view = visitorLoginView
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: #selector(visitorWillRegister))
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: #selector(visitorWillLogin))
    }
    func  visitorWillLogin() {
        //HYLog(#function)
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true) { 
            
        }
    }
    func visitorWillRegister() {
        //HYLog(#function)
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true) {
            
        }
    }

}
